package com.yinhe.music.yhmusic.singer.info;

import com.yinhe.music.yhmusic.base.BaseModel;
import com.yinhe.music.yhmusic.collect.CollectPresenter;
import com.yinhe.music.yhmusic.network.response.ResponseTransformer;

public class SingerInfoPresenter extends CollectPresenter<BaseModel, ISingerInfoContract.ISingerInfoView> implements ISingerInfoContract.ISingerInfoPresenter {
    @Override
    public void getSingerInfo(int id) {
        if (getView() == null) {
            return;
        }

        addSubscription(mModel.getSingerInfo(id)
                .compose(ResponseTransformer.handleResult())
                .compose(schedulerProvider.applySchedulers())
                .subscribe(singerList -> {
                            getView().setSingerInfoUI(singerList);
                        },
                        throwable -> {
                            getView().showMessage(throwable);
                        }));
    }

    @Override
    public void getInstrumentInfo(int id) {
        if (getView() == null) {
            return;
        }

        addSubscription(mModel.getInstrumentInfo(id)
                .compose(ResponseTransformer.handleResult())
                .compose(schedulerProvider.applySchedulers())
                .subscribe(instrumentListBean -> {
                            getView().seInstrumentInfoUI(instrumentListBean);
                        },
                        throwable -> {
                            getView().showMessage(throwable);
                        }));
    }
}
